 <?php 
 include "../../config.php";
 //This is the directory where images will be saved 
 $target = DOC_ROOT."/images/"; 
 $target = $target . basename( $_FILES['photo']['name']); 
 
 //This gets all the other information from the form 
 $name=$_POST['txtname']; 
 $desc=$_POST['txtdes']; 
 $size=$_POST['txtsize']; 
 $price=$_POST['txtprice'];
 $cateID=$_POST['cateid'];
 $ava=$_POST['txtava']; 
 $pic=($_FILES['photo']['name']); 
 $note=$_POST['txtnote']; 
 
// Connects to your Database 
$serverName = "SONVU-PC\SQLEXPRESS";
$connectionInfo = array( "Database"=>"shop", "UID"=>"sa", "PWD"=>"123456" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
     die( print_r( sqlsrv_errors(), true));
}
 $stmt = sqlsrv_query($conn,"INSERT INTO product (product_name, product_description,cartegory_id, unit_size, unit_price, available_colors, picture, note)
 VALUES ($name, $desc, $cateID,$size, $price, $ava, $pic, $note)");
 //Writes the information to the database 
 
 
 //Writes the photo to the server 
 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
 { 
 
 //Tells you if its all ok 
 echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; 
 } 
 else { 
 
 //Gives and error if its not 
 echo "Sorry, there was a problem uploading your file."; 
 } 
 ?> 